package com.yzf.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yzf.entity.Employee;
import com.yzf.entity.FileType;
import com.yzf.entity.Project;
import com.yzf.service.FIleService;
import com.yzf.util.web.ServletUtil;

public class new_files extends HttpServlet {

	private static final long serialVersionUID = 1L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		ServletUtil.forword(request, response, "new_file");
		
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String name = request.getParameter("name");
		Project p = (Project) ServletUtil.getSession(request).getAttribute("project");
		Employee e = (Employee) ServletUtil.getSession(request).getAttribute("employee");
		
		FIleService fileservice = new FIleService();
		fileservice.save(name,p.getId(),e.getId());
		
		List<FileType> list = fileservice.findAll(p.getId());
		ServletUtil.setRequestAttribute("list", list, request);
		ServletUtil.forword(request, response, "file");
	}

}
